#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "OpenglWidget.h"
#include <QBoxLayout>
#include <QFileDialog>
#include <QDir>
#include <QDirIterator>
#include <QSettings>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QMimeData>
#include <QFileInfo>
#include <QLabel>
#include <QSpacerItem>
#include <QSettings>
#include "settings.h"
#include <QThread>
#include "ImagePreloading.h"
#include <QPainter>
#include "image.h"
QT_BEGIN_NAMESPACE
namespace Ui
{
    class MainWindow;
}
QT_END_NAMESPACE

class Widget : public QMainWindow
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = nullptr);
    ~Widget();
    struct images
    {
        QImage image;
        QString message;
    };

protected:
    virtual void keyPressEvent(QKeyEvent *event) override;
    virtual void contextMenuEvent(QContextMenuEvent *event) override;
    virtual void dragEnterEvent(QDragEnterEvent *event) override;
    virtual void dropEvent(QDropEvent *event) override;
    virtual void closeEvent(QCloseEvent *event) override;

private:
    Ui::MainWindow *ui;
    OpenglWidget *openglWidget;
    QBoxLayout *m_layout;
    QLabel *m_page_label_count, *m_page_lable_cur;

    QVector<QString> imageFileNames;
    QString path;
    int currentImageIndex = 0;
    QLabel *m_statusbar_message, *m_statusbar_app_version;
    QHBoxLayout *m_statusbar_layout;

    settingQDialog *settingsDialog;
    QSettings sets;

    QThread *thread;
    ImagePreloading *preloading;
    QString message;
    imageNo360 *imageNo360Widget;

signals:
    void signalLoadImage(QStringList filePaths, int index);
    void signalClearImage();

private:
    void loadImages();
    void loadDir();
    void loadImagesInfo();
    void help();
    bool is360(QString &file);
};

#endif // MAINWINDOW_H
